package com.deyuanyun.pic.pig.app.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.deyuanyun.pic.common.dto.BasicDataByFind;
import com.deyuanyun.pic.common.dto.Result;
import com.deyuanyun.pic.common.exception.InterfaceCode;
import com.deyuanyun.pic.common.util.CommonUtil;
import com.deyuanyun.pic.common.util.RequestUtil;
import com.deyuanyun.pic.common.util.ResponseUtil;
import com.deyuanyun.pic.common.util.ajax.AjaxResponse;
import com.deyuanyun.pic.pig.app.domain.PigResults;
import com.deyuanyun.pic.pig.app.domain.PigTaskPoint;
import com.deyuanyun.pic.pig.app.service.PigService;
import com.deyuanyun.pic.settings.controller.dto.MyFileVO;
import com.deyuanyun.pic.settings.service.base.AttachmentService;
import com.deyuanyun.pic.settings.service.base.UploadService;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("/app")
public class PigController {
    @Resource
    private PigService pigService;

    @Resource
    private AttachmentService attachmentService;

    @Resource
    private UploadService uploadService;

    @RequestMapping("/getUserName")
    @ResponseBody
    public void getUserName(String Param, HttpServletResponse rep) {
        Map mapMarks = new HashMap();
        JSONObject obj = JSON.parseObject(Param);
        if (obj == null) {
            mapMarks.put("Code", InterfaceCode.PARAMETER_FAIL.getCode());
            mapMarks.put("Msg", InterfaceCode.PARAMETER_FAIL.getLabel());
            AjaxResponse.sendText(rep, JSON.toJSONString(mapMarks));
            return;
        }
        String Account = obj.getString("Account").trim();
        Map<String, Object> map = pigService.getUserName(Account);
        AjaxResponse.sendText(rep, JSON.toJSONString(map));
    }

    @RequestMapping("/loginApp")
    @ResponseBody
    public void login(String Param, HttpServletResponse rep) {

        Map<String, Object> mapMarks = pigService.login(Param);
        AjaxResponse.sendText(rep, JSON.toJSONString(mapMarks));

    }

    @RequestMapping("/logoutApp")
    @ResponseBody
    public void getlogputApp(String Param, HttpServletRequest request,
                             HttpServletResponse rep) {
        Map mapMarks = new HashMap();
        mapMarks.put("Code", InterfaceCode.SUCCESS.getCode());
        mapMarks.put("Msg", InterfaceCode.SUCCESS.getLabel());
        String map1 = JSON.toJSONString(mapMarks);
        AjaxResponse.sendText(rep, map1);
        request.getSession().removeAttribute("App_User_");
        // SecurityUtils.removeUser(request);
        // org.apache.shiro.SecurityUtils.getSubject().logout();

    }

    @RequestMapping("/getTasks")
    @ResponseBody
    public void getTasks(String Param, HttpServletResponse rep) {

        Map mapMarks = new HashMap();
        JSONObject obj = JSON.parseObject(Param);
        if (obj == null) {
            mapMarks.put("Code", InterfaceCode.PARAMETER_FAIL.getCode());
            mapMarks.put("Msg", InterfaceCode.PARAMETER_FAIL.getLabel());
            String map1 = JSON.toJSONString(mapMarks);
            AjaxResponse.sendText(rep, map1);
            return;
        }
        String UserID = obj.getString("UserID");
        this.checkUser(UserID, rep);
        BasicDataByFind find = new BasicDataByFind();
        if (null != obj.getInteger("PageNum")) {
            find.setCurrent(obj.getInteger("PageNum"));
        }
        if (null != obj.getInteger("PageSize")) {
            find.setPageCount(obj.getInteger("PageSize"));
        }
        int pageCount = 20;
        if (null != find.getCurrent()) {
            pageCount = find.getCurrent();
        }
        int current = 1;
        if (null != find.getPageCount()) {
            current = find.getPageCount();
        }
        PageHelper.startPage(pageCount, current);

        HashMap<String, Object> map = null;
        try {
            map = pigService.findTask();
            if (map != null && map.size() > 0) {
                mapMarks.put("Result", map);
            }
            mapMarks.put("Code", InterfaceCode.SUCCESS.getCode());
            mapMarks.put("Msg", InterfaceCode.SUCCESS.getLabel());
            String map1 = JSON.toJSONString(mapMarks);
            AjaxResponse.sendText(rep, map1);

        } catch (Exception e) {
            mapMarks.put("Code", InterfaceCode.SERVICE_FAIL.getCode());
            mapMarks.put("Msg", InterfaceCode.SERVICE_FAIL.getLabel());
            String map1 = JSON.toJSONString(mapMarks);
            AjaxResponse.sendText(rep, map1);
        }

    }

    @RequestMapping("/getTaskInfo")
    @ResponseBody
    public ModelAndView searchTask(String Param) {
        ModelAndView mav = new ModelAndView();
        JSONObject obj = JSON.parseObject(Param);
        String UserID = obj.getString("UserID");
        String taskId = obj.getString("TaskID");
        // this.checkUser(mav, rep);
        HashMap<String, Object> map = null;
        try {
            map = pigService.getTaskInfo(taskId);
            mav.addObject("Result", map);
            mav.addObject("Code", InterfaceCode.SUCCESS.getCode());
            mav.addObject("Msg", InterfaceCode.SUCCESS.getLabel());
        } catch (Exception e) {
            mav.addObject("Code", InterfaceCode.SERVICE_FAIL.getCode());
            mav.addObject("Msg", InterfaceCode.SERVICE_FAIL.getLabel());
        }

        return mav;
    }

    @RequestMapping("/searchTask")
    public ModelAndView searchTask(String UserID, String pipeName,
                                   Integer PageNum, Integer PageSize) {
        ModelAndView mav = new ModelAndView();
        // this.checkUser(mav,rep);
        BasicDataByFind find = new BasicDataByFind();
        find.setPageCount(PageSize);
        find.setCurrent(PageNum);
        int pageCount = 10;
        if (null != find.getPageCount()) {
            pageCount = find.getPageCount();
        }
        int current = 1;
        if (null != find.getCurrent()) {
            current = find.getCurrent();
        }
        PageHelper.startPage(current, pageCount);
        ;
        Result result = null;
        try {
            mav.addObject(result);
            mav.addObject("code", InterfaceCode.SUCCESS.getCode());
            mav.addObject("msg", InterfaceCode.SUCCESS.getLabel());
        } catch (Exception e) {
            mav.addObject("code", InterfaceCode.SERVICE_FAIL.getCode());
            mav.addObject("msg", InterfaceCode.SERVICE_FAIL.getLabel());
        }

        return mav;
    }

    @RequestMapping("/getPoints")
    @ResponseBody
    public void getTaskPoints(String Param, HttpServletResponse rep) {
        Map mapMarks = new HashMap();
        JSONObject obj = JSON.parseObject(Param);
        String UserID = obj.getString("UserID");
        String taskId = obj.getString("TaskID");
        this.checkUser(UserID, rep);
        HashMap<String, Object> map = null;
        try {
            map = pigService.findMarker(taskId);
            if (!map.isEmpty()) {
                mapMarks.put("Result", map);
            }
            mapMarks.put("Code", InterfaceCode.SUCCESS.getCode());
            mapMarks.put("Msg", InterfaceCode.SUCCESS.getLabel());
            String map1 = JSON.toJSONString(mapMarks);
            AjaxResponse.sendText(rep, map1);
        } catch (Exception e) {
            mapMarks.put("Code", InterfaceCode.SERVICE_FAIL.getCode());
            mapMarks.put("Msg", InterfaceCode.SERVICE_FAIL.getLabel());
            String map1 = JSON.toJSONString(mapMarks);
            AjaxResponse.sendText(rep, map1);
        }

    }

    @RequestMapping("/getTaskTypes")
    public ModelAndView getTaskTypes(String UserID) {
        ModelAndView mav = new ModelAndView();
        // this.checkUser(UserID,rep);
        Result result = null;
        try {
            result = pigService.getTaskTypes();
            mav.addObject(result);
            mav.addObject("Code", InterfaceCode.SUCCESS.getCode());
            mav.addObject("Msg", InterfaceCode.SUCCESS.getLabel());
        } catch (Exception e) {
            mav.addObject("Code", InterfaceCode.SERVICE_FAIL.getCode());
            mav.addObject("Msg", InterfaceCode.SERVICE_FAIL.getLabel());
        }

        return mav;
    }

    @RequestMapping("/getConfigs.json")
    @ResponseBody
    public void getConfigs(String Param, HttpServletResponse rep) {
        Map mapMarks = new HashMap();
        JSONObject obj = JSON.parseObject(Param);
        String UserID = obj.getString("UserID");
        this.checkUser(UserID, rep);
        HashMap<String, Object> map = new HashMap<String, Object>();
        try {
            map = pigService.getConfigs();
            if (map != null && map.size() > 0) {
                mapMarks.put("Result", map);
            }

            mapMarks.put("Code", InterfaceCode.SUCCESS.getCode());
            mapMarks.put("Msg", InterfaceCode.SUCCESS.getLabel());
            String map1 = JSON.toJSONString(mapMarks);
            AjaxResponse.sendText(rep, map1);
        } catch (Exception e) {
            mapMarks.put("Code", InterfaceCode.SERVICE_FAIL.getCode());
            mapMarks.put("Msg", InterfaceCode.SERVICE_FAIL.getLabel());
            String map1 = JSON.toJSONString(mapMarks);
            AjaxResponse.sendText(rep, map1);
        }

    }

    /**
     * 获取发球点信息（skoda系统）
     *
     * @param UserID
     * @param TaskId
     * @param SendID
     * @param rep
     */
    @RequestMapping("/getSendInfo")
    public void getSendInfo(String UserID, String TaskId, String SendID,
                            HttpServletResponse rep) {
        ModelAndView mav = new ModelAndView();
        this.checkUser(UserID, rep);
        JSONObject object = new JSONObject();
        object.put("key", null);
        try {
            PrintWriter out = rep.getWriter();
            out.print(object);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    @RequestMapping("/getBackInfo")
    public void getBackInfo(String UserID, String TaskId, String BackID,
                            HttpServletResponse res) {
        JSONObject object = new JSONObject();
        object.put("key", null);
        try {
            PrintWriter out = res.getWriter();
            out.print(object);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @RequestMapping("/getMarkInfo")
    public void getBackInfo(String Param, HttpServletResponse res) {
        JSONObject object = new JSONObject();
        object.put("key", null);
        try {
            PrintWriter out = res.getWriter();
            out.print(object);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @RequestMapping("/putSendInfo")
    @ResponseBody
    public void putSendInfo(String Param, HttpServletResponse rep) {
        Map mapMarks = new HashMap();
        JSONObject obj = JSON.parseObject(Param);
        try {
            String UserID = obj.getString("UserID");
            this.checkUser(UserID, rep);
            String taskId = obj.getString("TaskID");
            String Sender = obj.getString("RecordUser");
            String user = obj.getString("User");
            Date date = obj.getDate("Time");
            String remark = obj.getString("Remark");
            JSONArray picture = obj.getJSONArray("Pics");
            PigResults result = new PigResults();
            if (obj.getString("Flow") != null) {
                result.setSendBallsFlow(new BigDecimal(obj.getString("Flow")));
            }
            if (obj.getString("OutPressure") != null) {
                result.setSendBallsPressureFrom(new BigDecimal(obj
                        .getString("OutPressure")));
            }
            if (obj.getString("InPressure") != null) {
                result.setSendBallsPressureTo(new BigDecimal(obj
                        .getString("InPressure")));
            }
            if (obj.getString("PressureGap") != null) {
                result.setSendPressure(new BigDecimal(obj
                        .getString("PressureGap")));
            }
            if (obj.getString("Interference") != null) {
                result.setSendInterference(new BigDecimal(obj
                        .getString("Interference")));
            }
            if (obj.getString("PipeDiameter") != null) {
                result.setInterDiameter(new BigDecimal(obj
                        .getString("PipeDiameter")));
            }
            int CleanType = obj.getIntValue("CleanType");
            String CleanTypeID = obj.getString("CleanTypeID");
            String CleanTool = obj.getString("CleanTool");
            String id = CommonUtil.getUUID();
            // 生成发球记录时间
            Date sendRecordtime = new Date();
            result.setSendRecordtime(sendRecordtime);
            result.setPiggngTaskId(taskId);
            result.setSendRecrder(Sender);
            result.setSendUser(user);
            result.setSendBallsTime(date);
            result.setSendRemark(remark);
            result.setPiggingType(CleanTypeID);
            if (CleanType == 1) {
                result.setPigType(CleanTool);
            } else {
                result.setDetectorType(CleanTool);
            }
            pigService.insertSendInfo(result);
            mapMarks.put("Code", InterfaceCode.SUCCESS.getCode());
            mapMarks.put("Msg", InterfaceCode.SUCCESS.getLabel());
            String map1 = JSON.toJSONString(mapMarks);
            AjaxResponse.sendText(rep, map1);
        } catch (Exception e) {
            mapMarks.put("Code", InterfaceCode.SERVICE_FAIL.getCode());
            mapMarks.put("Msg", InterfaceCode.SERVICE_FAIL.getLabel());
            String map1 = JSON.toJSONString(mapMarks);
            AjaxResponse.sendText(rep, map1);
        }

    }

    @RequestMapping("/putBackInfo")
    @ResponseBody
    public void putBackInfo(String Param, HttpServletResponse rep) {
        Map mapMarks = new HashMap();
        JSONObject obj = JSON.parseObject(Param);
        HashMap<String, Object> map = null;
        try {
            String UserID = obj.getString("UserID");
            this.checkUser(UserID, rep);
            String BackID = obj.getString("ID");
            String taskId = obj.getString("TaskID");
            String Backer = obj.getString("RecordUser");
            String user = obj.getString("User");
            Date BackTime = obj.getDate("Time");
            String Remark = obj.getString("Remark");
            JSONArray picture = obj.getJSONArray("Pics");
            PigResults results = new PigResults();
            if (obj.getString("OutPressure") != null) {
                results.setTheBallsPressureFrom(new BigDecimal(obj
                        .getString("OutPressure")));
            }
            if (obj.getString("InPressure") != null) {
                results.setTheBallsPressureTo(new BigDecimal(obj
                        .getString("InPressure")));
            }
            if (obj.getString("Flow") != null) {
                results.setTheBallsFlow(new BigDecimal(obj.getString("Flow")));
            }
            if (obj.getString("MaxPressureGap") != null) {
                results.setMaxPushPressure(new BigDecimal(obj
                        .getString("MaxPressureGap")));
            }
            if (obj.getString("DumpGas") != null) {
                results.setVentGasVolume(new BigDecimal(obj
                        .getString("DumpGas")));
            }
            if (obj.getString("GasTemperature") != null) {
                results.setAvgTempreture(new BigDecimal(obj
                        .getString("GasTemperature")));
            }
            if (obj.getString("GasDensity") != null) {
                results.setGasRelativedEnsity(new BigDecimal(obj
                        .getString("GasDensity")));
            }
            if (obj.getString("PassGas") != null) {
                results.setActualPassGasVolume(new BigDecimal(obj
                        .getString("PassGas")));
            }
            if (obj.getString("WasteWater") != null) {
                results.setSewage(new BigDecimal(obj.getString("WasteWater")));
            }
            if (obj.getString("Waste") != null) {
                results.setDirt(new BigDecimal(obj.getString("Waste")));
            }
            if (obj.getString("ToolMile") != null) {
                results.setPigRunLength(new BigDecimal(obj
                        .getString("ToolMile")));
            }
            if (obj.getString("ToolSpeed") != null) {
                results.setAvgRate(new BigDecimal(obj.getString("ToolSpeed")));
            }
            if (obj.getString("Interference") != null) {
                results.setSendInterference(new BigDecimal(obj
                        .getString("Interference")));
            }
            if (obj.getString("CompressFactor") != null) {
                results.setCompressionCoefficient(new BigDecimal(obj
                        .getString("CompressFactor")));
            }
            String ToolRemark = obj.getString("ToolRemark");
            String DirtyRemark = obj.getString("DirtyRemark");
            int CleanType = obj.getIntValue("CleanType");
            String CleanTypeID = obj.getString("CleanTypeID");
            String CleanTool = obj.getString("CleanTool");

            // 生成收球记录时间
            Date recordtime = new Date();
            results.setRecordtime(recordtime);
            results.setPiggngTaskId(taskId);
            results.setBackBallsTime(BackTime);
            results.setRecrder(Backer);
            results.setRecrderUser(user);
            results.setSendRemark(Remark);
            results.setDirtdescRiption(DirtyRemark);
            results.setPiggingType(CleanTypeID);
            results.setPigDescribe(ToolRemark);
            if (CleanType == 0) {
                mapMarks.put("Code", InterfaceCode.PARAMETER_FAIL.getCode());
                mapMarks.put("Msg", InterfaceCode.PARAMETER_FAIL.getLabel());
                String map1 = JSON.toJSONString(mapMarks);
                AjaxResponse.sendText(rep, map1);
                return;
            } else if (CleanType == 1) {
                results.setPigType(CleanTool);
            } else if (CleanType == 2) {
                results.setDetectorType(CleanTool);
            }

            pigService.updateBackInfo(results);
            mapMarks.put("Code", InterfaceCode.SUCCESS.getCode());
            mapMarks.put("Msg", InterfaceCode.SUCCESS.getLabel());
            String map1 = JSON.toJSONString(mapMarks);
            AjaxResponse.sendText(rep, map1);
        } catch (Exception e) {
            e.printStackTrace();
            mapMarks.put("Code", InterfaceCode.SERVICE_FAIL.getCode());
            mapMarks.put("Msg", InterfaceCode.SERVICE_FAIL.getLabel());
            String map1 = JSON.toJSONString(mapMarks);
            AjaxResponse.sendText(rep, map1);
        }

    }

    @RequestMapping("passBall")
    @ResponseBody
    public void passBall(String Param, HttpServletResponse rep) {
        BigDecimal mile = null;
        Map mapMarks = new HashMap();
        JSONObject obj = JSON.parseObject(Param);
        int type = obj.getIntValue("Type");
        String taskId = obj.getString("TaskID");
        String ID = obj.getString("ID");
        Date passTime = obj.getDate("Time");
        String UserID = obj.getString("UserID");
        if (obj.getString("Mile") != null) {
            mile = new BigDecimal(obj.getString("Mile"));
        }
        this.checkUser(UserID, rep);
        try {
            pigService.passBall(taskId, ID, passTime, mile, type);
            mapMarks.put("Code", InterfaceCode.SUCCESS.getCode());
            mapMarks.put("Msg", InterfaceCode.SUCCESS.getLabel());
            String map1 = JSON.toJSONString(mapMarks);
            AjaxResponse.sendText(rep, map1);
        } catch (Exception e) {
            e.printStackTrace();
            mapMarks.put("Code", InterfaceCode.SERVICE_FAIL.getCode());
            mapMarks.put("Msg", InterfaceCode.SERVICE_FAIL.getLabel());
            String map1 = JSON.toJSONString(mapMarks);
            AjaxResponse.sendText(rep, map1);
        }

    }

    @RequestMapping("putMarkInfo")
    @ResponseBody
    public void postMarkInfo(String Param, HttpServletResponse rep) {
        Map mapMarks = new HashMap();
        BigDecimal mile = null;
        JSONObject obj = JSON.parseObject(Param);
        String MarkId = obj.getString("ID");
        String Marker = obj.getString("User");
        Date passtime = obj.getDate("Time");
        String UserID = obj.getString("UserID");
        this.checkUser(UserID, rep);
        String taskId = obj.getString("TaskID");
        Date arriveTime = obj.getDate("ArriveTime");
        String remark = obj.getString("Remark");
        JSONArray picture = obj.getJSONArray("Pics");
        if (obj.getString("Mile") != null) {
            mile = new BigDecimal(obj.getString("Mile"));
        }
        PigTaskPoint point = new PigTaskPoint();
        point.setId(MarkId);
        point.setArriveUser(Marker);
        point.setRecrder(Marker);
        point.setArriveTime(arriveTime);
        point.setPassTime(passtime);
        point.setMile(mile);
        point.setPiggngTaskId(taskId);
        point.setCreateRemark(remark);

        try {
            pigService.updateMarker(point);

            mapMarks.put("Code", InterfaceCode.SUCCESS.getCode());
            mapMarks.put("Msg", InterfaceCode.SUCCESS.getLabel());
            String map1 = JSON.toJSONString(mapMarks);
            AjaxResponse.sendText(rep, map1);
        } catch (Exception e) {
            mapMarks.put("Code", InterfaceCode.SERVICE_FAIL.getCode());
            mapMarks.put("Msg", InterfaceCode.SERVICE_FAIL.getLabel());
            String map1 = JSON.toJSONString(mapMarks);
            AjaxResponse.sendText(rep, map1);
        }

    }

    /**
     * 人到达跟踪点接口
     */
    @RequestMapping("arriveMark")
    @ResponseBody
    public void arriveMark(String Param, HttpServletResponse rep) {
        Map mapMarks = new HashMap();
        JSONObject obj = JSON.parseObject(Param);
        String taskId = obj.getString("TaskID");
        String ID = obj.getString("ID");
        Date time = obj.getDate("Time");
        String user = obj.getString("User");
        String UserID = obj.getString("UserID");
        this.checkUser(UserID, rep);
        PigTaskPoint point = new PigTaskPoint();
        point.setId(ID);
        point.setArriveTime(time);
        point.setPiggngTaskId(taskId);
        point.setArriveUser(user);
        point.setRecrder(user);
        try {
            pigService.arriveMark(point);

            mapMarks.put("Code", InterfaceCode.SUCCESS.getCode());
            mapMarks.put("Msg", InterfaceCode.SUCCESS.getLabel());
            String map1 = JSON.toJSONString(mapMarks);
            AjaxResponse.sendText(rep, map1);
        } catch (Exception e) {
            mapMarks.put("Code", InterfaceCode.SERVICE_FAIL.getCode());
            mapMarks.put("Msg", InterfaceCode.SERVICE_FAIL.getLabel());
            String map1 = JSON.toJSONString(mapMarks);
            AjaxResponse.sendText(rep, map1);
        }

    }

    /**
     * 上传附件
     *
     * @param multipartFiles
     * @param request
     * @param response
     * @throws Exception
     */
    @RequestMapping("/upload")
    @ResponseBody
    public void saveUploadFile(@RequestParam(value = "file", required = false) MultipartFile[] multipartFiles, HttpServletRequest request, HttpServletResponse response) throws Exception {
        Map param = RequestUtil.parseRequestParamToHashMap(request);
        MyFileVO fileVO = new MyFileVO();
        String businessId = param.get("bid").toString();
        String source = null;
        if ("1".equals(param.get("type"))) {
            source = "PIC_PIG_BALL_SEND";
        } else if ("2".equals(param.get("type"))) {
            source = "PIC_PIG_TASK_POINT";
        } else if ("3".equals(param.get("type"))) {
            source = "PIC_PIG_BALL_BACK";
        }
        fileVO.setBusinessId(businessId);
        fileVO.setType(source);
        StringBuffer result = new StringBuffer("{\"status\":");
        try {
            String res = uploadService.saveStorageFile(multipartFiles[0], fileVO);
            String id = org.apache.commons.lang.StringUtils.substringBetween(res, "[", "]");
            String path = org.apache.commons.lang.StringUtils.substringBetween(res, "{", "}");
            if (org.apache.commons.lang.StringUtils.isNotBlank(path)) {
                result.append("0,").append("\"id\":").append("\"")
                        .append(id).append("\"");
                result.append(",\"url\":").append("\"")
                        .append(path)

                        .append("\"}");
            }
        } catch (Exception e) {
            result.append("1,").append("\"err\":\"").append(e.getMessage())
                    .append("\"}");
        }
        ResponseUtil.printl(response, result.toString(), "json");
    }

    private void checkUser(String UserID, HttpServletResponse rep) {
        Map mapMarks = new HashMap();
        if (UserID == null) {
            mapMarks.put("Code", InterfaceCode.PARAMETER_FAIL.getCode());
            mapMarks.put("Msg", InterfaceCode.PARAMETER_FAIL.getLabel());
            String map1 = JSON.toJSONString(mapMarks);
            AjaxResponse.sendText(rep, map1);
            return;
        }
        if (pigService.findUserId(UserID) == null) {
            mapMarks.put("Code", InterfaceCode.USER_FAIL.getCode());
            mapMarks.put("Msg", InterfaceCode.USER_FAIL.getLabel());
            String map1 = JSON.toJSONString(mapMarks);
            AjaxResponse.sendText(rep, map1);
            return;
        }
        return;
    }

}
